/**
 * 
 */
package it.polimi.swimv2.entities;

import java.io.Serializable;

import javax.persistence.ManyToOne;

/**
 * @author Jacopo
 * 
 */
public class FriendshipDataPK implements Serializable {

	private static final long serialVersionUID = 1L;
	@ManyToOne
	public User user;
	@ManyToOne
	public User friend;

	public FriendshipDataPK() {
		super();
	}

	public FriendshipDataPK(User username, User friend) {
		this.user = username;
		this.friend = friend;
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((friend == null) ? 0 : friend.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof FriendshipDataPK))
			return false;
		FriendshipDataPK other = (FriendshipDataPK) obj;
		if (friend == null) {
			if (other.friend != null)
				return false;
		} else if (!friend.equals(other.friend))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}

}
